package com.lwei.tallybook.service.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lwei.tallybook.base.domain.Dictionary;
import com.lwei.tallybook.service.mapper.DictionaryMapper;
import com.lwei.tallybook.service.service.DictionaryService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author sks.lwei
 */
@Service
public class DictionaryServiceImpl extends ServiceImpl<DictionaryMapper, Dictionary> implements DictionaryService {

    @Override
    public List<Dictionary> listDictionaryByType(String type) {
        QueryWrapper<Dictionary> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("dictionary_type", type);
        return super.list(queryWrapper);
    }

    @Override
    public Dictionary getDictionaryByKey(String key) {
        QueryWrapper<Dictionary> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("dictionary_key", key);
        return super.getOne(queryWrapper);
    }
}
